﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZR.Model.Models.ProductionControl
{
    [SugarTable("Cks_PlcDataPosition")]
    [Table(Name = "Cks_PlcDataPosition")]
    public class CksPlcDataPosition : BaseEntity
    {
        [Column(IsIdentity =true,IsPrimary =true)]
        public int Id {  get; set; }

        public int PlcId {  get; set; }

        public string WorkStationCode {  get; set; }
        public int Module { get; set; }
        public int BlockDb {  get; set; }

        public int BlockLength {  get; set; }

        public decimal BytePosition {  get; set; }

        public int ByteLength {  get; set; }
        /// <summary>
        /// 解析类型 eg: bool\string\byte\...
        /// </summary>
        public string ParseType { get; set; }
        /// <summary>
        /// 作用类型 0 常规数据、1订阅数据、2 MES心跳、3 PLC心跳、4实时采集 5 数据采集
        /// 6 订阅+保存结果 7PLC确认 8 上传工艺参数 9 请求加工
        /// </summary>
        public int EffectType {  get; set; }
        /// <summary>
        /// 动作Id，仅订阅数据生效，实例化对应的执行操作类 
        /// </summary>
        public int ActionId { get; set; }

        public string ActionKey { get; set; }
        /// <summary>
        /// 关联动作Id 
        /// </summary>
        public int LinkActionId { get; set; }
        /// <summary>
        /// 动作下的步骤编号 
        /// </summary>
        public int StepId { get; set; }
        /// <summary>
        /// 数据分类 1 常规读取 2 写入回复信号 ...(可扩展，eg:子篮码、底板码)
        /// 1XXX:读取某种编码 2XXX:写入某种编码
        /// </summary>
        public int DataKind { get; set; }

        public string Description { get; set; }


        public bool Nullity { get; set; }
        public int DataId { get; set; }
        /// <summary>
        /// 是否监听进行后续处理
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        [Column(IsIgnore = true)]
        public bool IsListen
        {
            get
            {

                switch (EffectType)
                {
                    case 0:
                    case 2:
                    case 3:
                        return false;
                    default:
                        break;
                }
                return true;
            }
        }

        public int LocationId { get; set; }
    }
}
